package com.example.employ.controller;

/**
 * @author LYT0905
 * @date 2024/05/23/13:18
 */


import com.example.employ.common.convention.result.Result;
import com.example.employ.common.convention.result.Results;
import com.example.employ.dto.request.UserLoginReqDTO;
import com.example.employ.dto.request.UserRegisterReqDTO;
import com.example.employ.dto.response.UserLoginRespDTO;
import com.example.employ.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 用户管理
 */
@RestController()
@RequiredArgsConstructor
public class UserController {

    private final UserService userService;

    /**
     * 用户注册
     * @param requestParam 用户注册信息
     * @return void
     */
    @PostMapping("/api/recruit/v1/user")
    public Result<Void> register(@RequestBody UserRegisterReqDTO requestParam){
        userService.register(requestParam);
        return Results.success();
    }

    /**
     * 用户登录
     * @param requestParam 用户登录请求参数
     * @return token
     */
    @PostMapping("/api/recruit/v1/user/login")
    public Result<UserLoginRespDTO> login(@RequestBody UserLoginReqDTO requestParam){
        UserLoginRespDTO userLoginRespDTO = userService.login(requestParam);
        return Results.success(userLoginRespDTO);
    }
}
